#pragma once
#ifndef WORLDMODEL_H
#define WORLDMODEL_H

#include <vector>
using namespace std;
#include <d3dx9.h>

//forward declarations
class CWorldEntity;
class CEntityPlayer;

class CWorldModel
{
public:
	//mode
	enum eCameraMode
	{
		eModeFPS,
		eModeTPS
	};

private:
	//singleton variable
	static CWorldModel* instance;

	//container
	vector<CWorldEntity*> m_vectorEntity;

	//mode
	eCameraMode m_cameraMode;

	//index of certain entities
	int m_indexPlayer;
	int m_indexTerrain;
	int m_indexCamera;

	bool m_gameOver;
private:
	CWorldModel(void);
	~CWorldModel(void);

public:
	//singleton function
	static CWorldModel* getInstance(void);
	void close();

	//create entity
	void createEnemy(int gfxIndex, D3DXVECTOR3 initialPosition, float initialPitch, float initialYaw, float initialRoll, float speed, 
		bool collision, int indexSound, int soundDuration, float damage, float offsetY);
	void createSkyBox(int gfxIndex);
	void createTerrain(int gfxIndex);
	void createPlayer(int gfxIndex, D3DXVECTOR3 initialPosition, float initialPitch, float initialYaw, float initialRoll, float speed, float health, bool collision);
	void createCamera(float distanceZ, float distanceY);
	void createDecor(int gfxIndex, D3DXVECTOR3 initialPosition, float initialPitch, float initialYaw, float initialRoll, bool collision, float offsetY);

	void doUpdate(void);
	void doRender(void);

	//cameraMode
	eCameraMode getCameraMode(void);
	void setCameraMode(eCameraMode);

	//action functions
	void movePlayerForward(float amount);
	void movePlayerBackward(float amount);
	void strafePlayerLeft(float amount);
	void strafePlayerRight(float amount);
	void turnPlayerLeftRight(float amount);
	void playerLookUpDown(float amount);

	bool modeWireframe();

	float terrainFollowing(const D3DXVECTOR3* position);
	CWorldEntity* checkCollision(CWorldEntity* const);

	//gettors
	D3DXVECTOR3 getPlayerPosition()const;
	float getPlayerYaw()const;
	float getPlayerHealth()const;
	bool getGameOver()const;

};
#define WORLDMODEL CWorldModel::getInstance()

#endif